﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>个人信息</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	
	<script src="js/scripts/boot.js" type="text/javascript"></script>
	<link href="js/scripts/miniui/themes/blue/skin.css" rel="stylesheet" type="text/css" />
	
	<style type="text/css">
		html, body {
			margin: 0;
			padding: 0;
			border: 0;
			width: 100%;
			height: 100%;
			overflow: hidden;
		}
	</style>
</head>
<body>

<form id="form1">
	<div style="padding-left:11px;padding-bottom:5px;">
		<table>
			<tr>
				<td align="center" width="10%">用户名</td>
				<td width="23%">
					<input id="name" required="true" class="mini-textbox" 
					value="<%= session.getAttribute("nickName")%>" style="width: 100%; display: inline-block;" />
				</td>
			</tr>
			<tr>
				<td align="center" width="10%">密码</td>
				<td width="23%">
					<input id="password" type="password" required="true" class="mini-password" style="width: 100%; display: inline-block;" />
				</td>
			</tr>
			<tr>
				<td align="center" width="10%">确认密码</td>
				<td width="23%">
					<input id="repassword" type="password" required="true" class="mini-password" style="width: 100%; display: inline-block;" />
				</td>
			</tr>
		</table>
	</div>
    <div style="text-align:center;padding:10px;">               
           <a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>       
           <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>       
    </div>
</form>


	<script type="text/javascript">
		mini.parse();

        var form = new mini.Form("form1");
        function CloseWindow(action) {            
            if (action == "close" && form.isChanged()) {
                if (confirm("数据被修改了，是否先保存？")) {
                    return false;
                }
            }
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();            
        }
        
        function onOk() {
            //提交表单数据
            var form = new mini.Form("#form1"); 
    		var password = mini.get("password").getValue();
    		var repassword = mini.get("repassword").getValue();
            form.validate();
            if (form.isValid() == false) return;
            if (password != repassword){
            	alert("请输入相同的密码");
            	return;
            }
           
			$.ajax({
				type : "post",
				url : "/document/user/updateUser.do",
				data : {
					userId : '<%=session.getAttribute("userId")%>',
					userPwd : password
				},
				dataType : "JSON",
				success : function(t) {
					alert("密码修改成功");
					CloseWindow("save");
				}
			});
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }
        function SetData(data) {
        	
        }
        function GetData() {
            var o = form.getData();
            return o;
        }

	</script>

</body>
</html>